var e = require;
var t = module;
var o = exports;
var ii, nn = this && this.__extends || (ii = function (t, e) {
    return (ii = Object.setPrototypeOf || {
        __proto__: []
    }
        instanceof Array &&
        function (t, e) {
            t.__proto__ = e
        } ||
        function (t, e) {
            for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o])
        })(t, e)
},
    function (t, e) {
        function o() {
            this.constructor = t
        }
        ii(t, e),
            t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o)
    }
),
    rr = this && this.__awaiter ||
        function (t, e, o, i) {
            return new (o || (o = Promise))(function (n, a) {
                function r(t) {
                    try {
                        l(i.next(t))
                    } catch (e) {
                        a(e)
                    }
                }
                function s(t) {
                    try {
                        l(i.
                            throw(t))
                    } catch (e) {
                        a(e)
                    }
                }
                function l(t) {
                    var e;
                    t.done ? n(t.value) : (e = t.value, e instanceof o ? e : new o(function (t) {
                        t(e)
                    })).then(r, s)
                }
                l((i = i.apply(t, e || [])).next())
            })
        };
var oo = (this && this.__decorate) ||
    function (e, t, a, n) {
        var i,
            o = arguments.length,
            s = o < 3 ? t : null === n ? (n = Object.getOwnPropertyDescriptor(t, a)) : n;
        if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) s = Reflect.decorate(e, t, a, n);
        else
            for (var r = e.length - 1; r >= 0; r--)
                (i = e[r]) && (s = (o < 3 ? i(s) : o > 3 ? i(t, a, s) : i(t, a)) || s);
        return o > 3 && s && Object.defineProperty(t, a, s), s;
    }; Object.defineProperty(o, "__esModule", { value: !0 });
var a = e("BaseModuleUI"),
    n = e("NotifyEventType"),
    i = e("GlobalParams"),
    r = e("Game"),
    s = e("ObjectPool"),
    l = cc._decorator,
    _ = l.ccclass,
    c = l.property,
    d = (function (e) {
        function t() {
            var t = (null !== e && e.apply(this, arguments)) || this;
            return (
                (t.soldier_ske = null),
                (t.soldier_hp_mask = null),
                (t.soldier_skeleton = []),
                (t.be_hit_ske = null),
                (t.team_info = r.TeamInfo.rest_team),
                (t.node_info = null),
                (t.have_hp = 0),
                (t.is_die = !1),
                (t.soldier_kill_id = 0),
                t
            );
        }
        return (
            nn(t, e),
            (t.prototype.setNodeInfo = function (e) {
                if (
                    ((this.team_info = e.team),
                        (this.node_info = e.info),
                        (this.have_hp = this.node_info.ma_hp),
                        e.id < 2)
                ) {
                    var t = 0 == e.id ? (this.team_info % 2 == 0 ? 0 : 1) : this.team_info % 2 == 0 ? 2 : 3;
                    this.soldier_ske.skeletonData = this.soldier_skeleton[t];
                } else
                    2 == e.id &&
                        ((t = this.team_info % 2 == 0 ? 0 : 1),
                            (this.soldier_ske.skeletonData = this.soldier_skeleton[t]));
                (this.soldier_hp_mask.width = 77),
                    (this.soldier_hp_mask.children[0].active = this.team_info % 2 == i.GlobalParams.MatchMyIndex % 2),
                    (this.soldier_hp_mask.children[1].active = this.team_info % 2 != i.GlobalParams.MatchMyIndex % 2),
                    e.id < r.SoldierType.dragon_soldier
                        ? e.id == r.SoldierType.near_soldier
                            ? (this.soldier_kill_id = r.KillType.near_soldier)
                            : e.id == r.SoldierType.far_soldier
                                ? (this.soldier_kill_id = r.KillType.far_soldier)
                                : e.id == r.SoldierType.super_soldier && (this.soldier_kill_id = r.KillType.super_soldier)
                        : e.id == r.SoldierType.dragon_soldier
                            ? (this.soldier_kill_id = r.KillType.dragon)
                            : e.id == r.SoldierType.super_dragon_soldier && (this.soldier_kill_id = r.KillType.big_dragon),
                    (this.be_hit_ske.node.active = !1);
            }),
            (t.prototype.soldierBeHit = function (e, t) {
                var o = this;
                (this.have_hp -= e),
                    this.emitEvent(n.default.SEND_SHOW_BE_HIT_INFO, {
                        attack: e,
                        my_team: this.team_info == r.TeamInfo.left_team ? 0 : 1,
                        end_pos: cc.v2(this.node.getPosition().x, this.node.getPosition().y + 80)
                    }),
                    (this.soldier_hp_mask.width = (77 * this.have_hp) / this.node_info.ma_hp),
                    (this.be_hit_ske.node.active = !0),
                    this.be_hit_ske.setAnimation(0, "受击特效", !1),
                    this.have_hp <= 0 &&
                    !this.is_die &&
                    ((this.is_die = !0),
                        this.scheduleOnce(function () {
                            o.emitEvent(n.default.SEND_ROLE_BE_KILL_INFO, {
                                kill: t,
                                be_kill: o.soldier_kill_id,
                                team: o.team_info
                            }),
                                o.soldier_kill_id < r.KillType.dragon
                                    ? o.soldier_kill_id == r.KillType.super_soldier
                                        ? s.default.getInstance().Recovey(o.node, r.Pool_Type.super_soldier)
                                        : s.default.getInstance().Recovey(o.node, r.Pool_Type.soldier)
                                    : o.node.destroy();
                        }, 0.01));
            }),
            oo([c(sp.Skeleton)], t.prototype, "soldier_ske", void 0),
            oo([c(cc.Node)], t.prototype, "soldier_hp_mask", void 0),
            oo([c(sp.SkeletonData)], t.prototype, "soldier_skeleton", void 0),
            oo([c(sp.Skeleton)], t.prototype, "be_hit_ske", void 0),
            oo([_], t)
        );
    })(a.default);
o.default = d;
